
#ifndef _PROJECTZ_NUSER_NCOMMAND_CS_ITEM_INFO_REQ_H_
#define _PROJECTZ_NUSER_NCOMMAND_CS_ITEM_INFO_REQ_H_

#include "../../engine.h"

#include "../../User.h"

#include "../../NLogic/Bag.h"
#include "../../NLogic/Item.h"


namespace ProjectZ { namespace NCommand { namespace NWorld {


class CS_ITEM_INFO_REQ
{
public:
	static void OnExecute(User * pUser, ::Network::Packet * pPacket)
	{
		PREPARE_PACKET;

		int bag_type = 0;
		uint64_t item_seq = 0;
		pPacket->ParseMsg("%c%8d", & bag_type, & item_seq);

		NLogic::Bag * pBag = pUser->GetBag(static_cast<INVEN_BAG_TYPE>(bag_type));
		if (NULL == pBag)
		{
			DEBUGLOG("CS_ITEM_INFO_REQ NULL == pBag");

			::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
			pAck->Write2(ACK_UNKNOWN_ERROR);
			//* pAck << item_seq;
			//pItem->WriteToPacket(pAck);
			pAck->MakePacket(CMD_SC_ITEM_INFO_REQ);
			pUser->Send(pAck);

			return;
		}

		NLogic::Item * pItem = pBag->GetItem(item_seq);
		if (NULL == pItem)
		{
			DEBUGLOG("CS_ITEM_INFO_REQ NULL == pItem");

			::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
			pAck->Write2(ACK_UNKNOWN_ERROR);
			//* pAck << item_seq;
			//pItem->WriteToPacket(pAck);
			pAck->MakePacket(CMD_SC_ITEM_INFO_REQ);
			pUser->Send(pAck);

			return;
		}

		::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
		pAck->Write2(ACK_OK);
		* pAck << item_seq;
		pItem->WriteToPacket(pAck);
		pAck->MakePacket(CMD_SC_ITEM_INFO_REQ);
		pUser->Send(pAck);
	}
};

} /*NPVP*/ } /*NCommand*/ } /*ProjectZ*/

#endif /* _PROJECTZ_NUSER_NCOMMAND_CS_ITEM_INFO_REQ_H_ */
